<?php

require_once 'PipesImpl/Model/Meta/Column.php';

class Pipes_Model_Meta_Column implements PipesImpl_Model_Meta_Column
{
	private $_data = array();
	
	public function __construct(PipesImpl_Database_Reflection_Column $column, array $overrides = array()) {
		$this->_data['name'] = $column->getName();
		$this->_data['type'] = $column->getType();
		$this->_data['size'] = $column->getLength();
		$this->_data['visible'] = !$column->isTableId();
		$this->_data['required'] = $column->isRequired();
		$this->_data['default'] = $column->getDefault();
		
		$this->_data = array_merge($this->_data, $overrides);

		if (empty($this->_data['label'])) {
			$this->_data['label'] = $this->_data['name'];
		}
	}
	
	public function __get($key) {
		return $this->_data[$key];
	}
}
